package com.symaster.common.clipper2.engine;

import com.symaster.common.clipper2.core.PathType;

import java.util.Objects;

final class LocalMinima {

    ClipperBase.Vertex vertex;
    PathType polytype;
    boolean isOpen = false;

    LocalMinima() {
    }

    LocalMinima(ClipperBase.Vertex vertex, PathType polytype) {
        this(vertex, polytype, false);
    }

    LocalMinima(ClipperBase.Vertex vertex, PathType polytype, boolean isOpen) {
        this.vertex = vertex;
        this.polytype = polytype;
        this.isOpen = isOpen;
    }

    boolean opEquals(LocalMinima o) {
        return vertex == o.vertex;
    }

    boolean opNotEquals(LocalMinima o) {
        return vertex != o.vertex;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        LocalMinima that = (LocalMinima) o;
        return isOpen == that.isOpen && Objects.equals(vertex, that.vertex) && polytype == that.polytype;
    }

    @Override
    public int hashCode() {
        return Objects.hash(vertex, polytype, isOpen);
    }

    @Override
    protected LocalMinima clone() {
        LocalMinima varCopy = new LocalMinima();

        varCopy.vertex = this.vertex;
        varCopy.polytype = this.polytype;
        varCopy.isOpen = this.isOpen;

        return varCopy;
    }
}